/*
 * Copyright 2020-2030 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package com.gitee.minimalismstyle.fresh.simple.api.service

import com.gitee.minimalismstyle.fresh.common.api.annotation.ControllerFeignClient
import com.gitee.minimalismstyle.fresh.common.core.domain.QueryBody
import com.gitee.minimalismstyle.fresh.common.core.domain.QueryParams
import com.gitee.minimalismstyle.fresh.common.core.domain.R
import com.gitee.minimalismstyle.fresh.common.core.domain.Simple
import com.gitee.minimalismstyle.fresh.common.data.commons.service.LongModelBaseService
import com.gitee.minimalismstyle.fresh.simple.api.config.SimpleApiConst
import com.gitee.minimalismstyle.fresh.simple.api.model.SimpleSql
import io.swagger.annotations.Api
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestParam

/**
 * SQL定义业务接口
 * @author maoxiaodong
*/
@Api(value = "simpleSql", tags = ["SQL定义接口"])
@ControllerFeignClient(serviceId = SimpleApiConst.SERVICE_ID, ctx =SimpleApiConst.CTX, path = "/simpleSql")
interface SimpleSqlService: LongModelBaseService<SimpleSql>{

    @GetMapping("findByCode/{code}")
    fun findByCode(@PathVariable code: String): R<SimpleSql>

    @GetMapping("findSqlByCode/{code}")
    fun findSqlByCode(@PathVariable code: String): R<String>

    @PostMapping("executePageById/{id}")
    fun executePageById(@PathVariable id: Long, queryParams: QueryParams<Simple>): R<QueryBody<Simple>>

    @PostMapping("executePageByCode/{code}")
    fun executePageByCode(@PathVariable code: String, queryParams: QueryParams<Simple>): R<QueryBody<Simple>>

    @PostMapping("executePageBySimpleSql")
    fun executePageBySimpleSql(@RequestBody simpleSql: SimpleSql, @RequestParam queryParams: QueryParams<Simple>): R<QueryBody<Simple>>

    @PostMapping("executeSelectByCode/{code}")
    fun executeSelectByCode(@PathVariable code: String, params: Simple): R<List<Simple>>

    @PostMapping("executeUpdateByCode/{code}")
    fun executeUpdateByCode(@PathVariable code: String, params: Simple): R<Int>
}